Skip to content

Conversation

@hakandilek
Copy link
Contributor

@hakandilek hakandilek commented Feb 17, 2020

The final images somehow contain the following packages which are not necessary:

  • libmailutils5*
  • libmariadb3* (postgres:12+)
  • mailutils*
  • mariadb-common* (postgres:12+)
  • mysql-common*
  • libmariadbclient18* (postgres:11-)

It also makes sense to "autoremove" at the end to get rid of the packages which are no longer needed. Those packages are (for buster/postgres 12.2):

  • bzip2
  • file
  • guile-2.2-libs
  • libexpat1
  • libfribidi0
  • libgc1c2
  • libgsasl7
  • libidn11
  • libkyotocabinet16v5 libltdl7 liblzo2-2 libmagic-mgc libmagic1 libntlm0
  • libpython2.7
  • libpython2.7-minimal
  • libpython2.7-stdlib
  • libwrap0
  • mailutils-common
  • mime-support

@tianon
Copy link
Member

tianon commented Feb 17, 2020

In exploring the image, I believe most of this comes directly from the Recommends: on postgresql-common and postgresql-NN packages (since we don't use --no-install-recommends on their installations).

When I inspect those two packages for PostgreSQL 12, the full list of Recommends: is e2fsprogs, logrotate, and sysstat, none of which appear to be important for core PostgreSQL functionality, so I think the better solution here is probably to include --no-install-recommends consistently on all our apt-get install lines to avoid these packages in the first place.

We might need to add some back manually, but that's probably a good thing too:

$ apt-get purge -s --auto-remove -o APT::AutoRemove::RecommendsImportant=false
...
The following packages will be REMOVED:
  bzip2* cron* exim4-base* exim4-config* exim4-daemon-light* file* guile-2.2-libs* krb5-locales* libevent-2.1-6* libexpat1*
  libfribidi0* libgc1c2* libgnutls-dane0* libgpm2* libgsasl7* libidn11* libkyotocabinet16v5* libltdl7* liblzo2-2* libmagic-mgc*
  libmagic1* libmailutils5* libmariadb3* libntlm0* libpopt0* libpython2.7* libpython2.7-minimal* libpython2.7-stdlib*
  libsensors-config* libsensors5* libunbound8* libwrap0* logrotate* mailutils* mailutils-common* mariadb-common* mime-support*
  mysql-common* psmisc* sysstat* xz-utils*
...

@hakandilek
Copy link
Contributor Author

@tianon Thanks for the feedback. I've introduced --no-install-recommends where apt-get install is being made. Image size is reduced from 397MB to 314MB in the build output. That's around 80MB per image.

But I can't distinguish which of those packages (from your console output) need to be installed manually. If you can tell I can include them in the PR.

This results in a ~80MB image size reduction.
Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tianon tianon requested a review from yosifkit February 22, 2020 00:15
@hakandilek hakandilek requested review from yosifkit and removed request for yosifkit February 25, 2020 15:54
@yosifkit
Copy link
Member

I was worried that some of these packages might be required for create extension, but I did a quick test on a couple versions of the postgis/postgis image and it works fine. Are there any other popular extensions that could be worthwhile for a quick test before merging?

Apart from that, LGTM.

@yosifkit yosifkit merged commit 0a0f644 into docker-library:master Feb 26, 2020
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Feb 26, 2020
Changes:

- docker-library/postgres@0a0f644: Merge pull request docker-library/postgres#684 from hakandilek/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants